package com.qfedu.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * 概述:
 *
 * @Author: Tbh
 * @Date: 2022/6/22 15:07
 */

@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    private PasswordEncoder passwordEncoder;

    @Autowired
    private UserDetailsService userDetailsService;

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//        String encode = passwordEncoder.encode("1234");
//        auth.inMemoryAuthentication().withUser("jack").password(encode).roles("");
        auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder);
    }
}
